import type { RouteMeta, RouteRecordRaw } from 'vue-router'

export function buildMeta(data: RouteMeta = {}): RouteMeta {
  return {
    ...data,
    module: 'DNS',
  }
}
export default {
  path: '/',
  meta: buildMeta(),
  component: () => import('@/components/layout/DefaultLayout.vue'),
  children: [
    {
      path: '/dns',
      meta: buildMeta({ title: 'DNS' }),
      children: [
        {
          path: 'domain-analysis',
          name: 'DnsResolveDomain',
          component: () => import('@/views/dns/domain-analysis'),
          meta: {
            title: '域名解析',
            showPageHeader: true,
            showBack: false,
            activeMenu: 'DnsResolveDomain',
          },
        },
        {
          path: 'analysis-detail/:id/:name',
          name: 'DomainAnalysisDetail',
          component: () =>
            import('@/views/dns/domain-analysis/analysis-detail'),
          meta: buildMeta({
            title: '管理',
            breadcrumbs: [
              {
                title: '域名解析',
                to: { name: 'DnsResolveDomain' },
              },
            ],
            showPageHeader: true,
            showBack: false,
            activeMenu: 'DnsResolveDomain',
          }),
        },
        {
          path: 'instance-list',
          name: 'DnsInstanceList',
          component: () => import('@/views/dns/instance-list'),
          meta: {
            title: '实例管理',
            showPageHeader: true,
            showBack: false,
            activeMenu: 'DnsInstanceList',
          },
        },
        {
          path: 'instance-management/:id',
          name: 'DnsInstanceManagement',
          component: () =>
            import('@/views/dns/instance-list/detail/strategy-management'),
          meta: buildMeta({
            title: '管理',
            activeMenu: 'DnsInstanceList',
            breadcrumbs: [
              {
                title: '实例管理',
                to: { name: 'DnsInstanceList' },
              },
            ],
          }),
        },
        {
          path: 'address-pool-management/:module?',
          name: 'DnsAddressPoolManagement',
          component: () => import('@/views/dns/address-pool'),
          meta: buildMeta({
            title: '地址池管理',
            tabs: [
              { title: 'CDN 动态地址池', key: 'dynamic' },
              { title: '静态地址池', key: 'static' },
            ],
          }),
        },
        {
          path: 'ns-address',
          name: 'DnsNSAddress',
          component: () => import('@/views/dns/ns-address'),
          meta: {
            title: '服务器地址',
            showPageHeader: true,
            showBack: false,
            activeMenu: 'DnsNSAddress',
          },
        },
        {
          path: 'ns-node',
          name: 'DnsNSNode',
          component: () => import('@/views/dns/ns-node'),
          meta: {
            title: '服务器节点',
            showPageHeader: true,
            showBack: false,
            activeMenu: 'DnsNSNode',
          },
        },
        {
          path: 'ns-version',
          name: 'DnsNSVersion',
          component: () => import('@/views/dns/ns-version'),
          meta: {
            title: '版本管理',
            showPageHeader: true,
            showBack: false,
            currentActiveMenu: 'DnsNSVersion',
          },
        },
        // {
        //   path: 'dedicated',
        //   name: 'CouldComputingDedicatedGroup',
        //   component: () => import('@/views/cdn/group/dedicated'),
        //   meta: buildMeta({ title: '节点级联' }),
        // },
      ],
    },
  ],
} satisfies RouteRecordRaw
